package com.youchuang.action.user;

import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;
import com.youchuang.action.BaseAction;
import com.youchuang.bean.Indent;
import com.youchuang.bean.IndentItem;
import com.youchuang.common.Constant;
import com.youchuang.service.IndentService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * 用户评论订单和图书
 * 
 * @author Administrator
 *
 */
@Namespace(value = "/user")
@ParentPackage("shopping-default")
public class InsertCommentAction extends BaseAction {

	private Logger logger = Logger.getLogger(InsertCommentAction.class.getSimpleName());
	private String indentId;
	private Indent indent;
	private List<IndentItem> items;
	
	@Resource
	private IndentService indentService;

	@Action(value = "insertComment", results = {
			@Result(name = ActionSupport.SUCCESS, location = "/WEB-INF/jsp/user/comment_indent.jsp") })

	public String execute() throws Exception {
		logger.info("excetion is execute");

		indent = indentService.findIndentById(indentId);
		items = indentService.findIndentItemByIndentId(indentId);

		logger.info("response json indent = " + JSONObject.fromObject(indent).toString());
		logger.info("response json items = " + JSONArray.fromObject(items).toString());
		return Constant.SUCCESS;
	}

	public Logger getLogger() {
		return logger;
	}

	public void setLogger(Logger logger) {
		this.logger = logger;
	}

	public String getIndentId() {
		return indentId;
	}

	public void setIndentId(String indentId) {
		this.indentId = indentId;
	}

	public Indent getIndent() {
		return indent;
	}

	public void setIndent(Indent indent) {
		this.indent = indent;
	}

	public List<IndentItem> getItems() {
		return items;
	}

	public void setItems(List<IndentItem> items) {
		this.items = items;
	}

}
